﻿
using System ;
using System.IO ;

using MskEdit.Model ;

using MskEdit.Dxf.Model ;
using MskEdit.Dxf.Backend ;
using MskEdit.Msk.Model ;
using MskEdit.Msk.Backend ;


namespace MskEdit.Backend
{
    public static class ProjectIO {
        
        public static Project TryGetProject( DirectoryInfo directoryInfo, Project fallbackValue ) {
        
            MskDocument   mskDocument  = MskDocumentIO.TryGetMskDocument( directoryInfo, null ) ;
            
            if ( mskDocument == null )
                return fallbackValue ;

            DxfDocument[] dxfDocuments = DxfDocumentIO.GetDxfDocuments( directoryInfo ) ;
            
            if ( dxfDocuments.Length == 0 )
                return fallbackValue ;
                
            return new Project( mskDocument, dxfDocuments ) ;
            
        }
    }
}
